/*
 * Copyright 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
 */
package src.com.bjsxt.height.design016_test;

import java.util.concurrent.*;

/**
 * Description:
 *
 * @author wzz
 * @since: 1.0
 * Create Date Time: 2018/11/1 16:17
 * Update Date Time:
 */
public class Main {
    public static void main(String[] args) {
        //内存缓冲区
        BlockingQueue<Data> queue = new LinkedBlockingQueue<>(10);
        Provider p1 = new Provider(queue);
        Provider p2 = new Provider(queue);
        Provider p3 = new Provider(queue);

        Consumer c1 = new Consumer(queue);
        Consumer c2 = new Consumer(queue);
        Consumer c3 = new Consumer(queue);

        ExecutorService e = Executors.newCachedThreadPool();
        e.execute(p1);
        e.execute(p2);
        e.execute(p3);
        e.execute(c1);
        e.execute(c2);
        e.execute(c3);
        p1.stop();
        p2.stop();
        p3.stop();
    }
}
